package cn.zsxmlv.common.utils;

import com.baomidou.mybatisplus.plugins.Page;
import lombok.*;

import java.io.Serializable;
import java.util.List;

/**
 * @author: zs
 * @description: 分页工具类
 * @date: 2019/2/27 10:25
 */
@Data
@ToString
@Builder
@AllArgsConstructor
public class PageUtils implements Serializable {

    //总记录数
    private int totalCount;
    //每页记录数
    private int pageSize;
    //总页数
    private int totalPage;
    //当前页数
    private int currPage;
    //列表数据
    private List<?> list;

    /**
     * 分页
     */
    public PageUtils(Page<?> page) {
        this.list = page.getRecords();
        this.totalCount = (int)page.getTotal();
        this.pageSize = page.getSize();
        this.currPage = page.getCurrent();
        this.totalPage = (int)page.getPages();
    }

}
